package com.socket;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.UnknownHostException;

public class SocketClient {

	public static void main(String[] args) throws UnknownHostException, IOException {
		Socket s = new Socket("127.0.0.1", 5005);
		
		DataOutputStream dos = new DataOutputStream(s.getOutputStream());
		
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader bis = new BufferedReader(isr);
		String str = null;
		
		while(!"bye".equals(str = bis.readLine())){
			//System.out.println(str);
			dos.writeUTF(str);
			dos.flush();
			//bis.readLine();
			//bis.close();
			//bis = new BufferedReader(isr);
		}
		dos.writeUTF("bye");
		//dos.writeUTF("你好!");
		bis.close();
		dos.close();
		
		s.close();

	}

}
